package dao;

import order_cancel_subscription.SqlProcessor;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;


public class DAOTestBase {
	
	protected static SqlProcessor sqlProcessor; 
	protected Boolean changedDB = false;
	
	public static void setSqlProcessor(SqlProcessor sqlProc) {
		sqlProcessor = sqlProc;
	}
	
	@After
	public void tearDown() {
		if (changedDB) {
			sqlProcessor.executeSqlScript("scripts/db_schema.sql");
			sqlProcessor.executeSqlScript("scripts/test_data.sql");
			changedDB = Boolean.FALSE;
			System.out.println("AFTER");
		}
	}
	
	@AfterClass
	public static void restoreDBstate() {
		restoreDB();
		System.out.println("AFTER CLASS");
	}
	
	protected static void initDB() {

		sqlProcessor.executeSqlScript("scripts/db_schema.sql");
		sqlProcessor.executeSqlScript("scripts/test_data.sql");
	}
	
	protected static void restoreDB() {
		initDB();
	}
}
